using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class QuestNameButton : MonoBehaviour
{
    public Text QuestName;
    public QuestData_SO currentQuestData;
    public Text questContentText;


    private void Awake()
    {
        GetComponent<Button>().onClick.AddListener(UpdateQuestContent);
    }

    public void UpdateQuestContent()
    {
        questContentText.text = currentQuestData.description;
        QuestUI.Instance.SetupRequirmentList(currentQuestData);
        foreach (Transform reward in QuestUI.Instance.rewardTransform)
        {
            Destroy(reward.gameObject);
        }
        foreach (var rewardItem in currentQuestData.rewardItems)
        {
            QuestUI.Instance.SetupRewardItemList(rewardItem.itemData,rewardItem.amount);
        }
    }

    public void SetupQuestName(QuestData_SO questData)
    {
        currentQuestData = questData;
        if (questData.isComplete)
        {
            QuestName.text = questData.questName + " （完成） ";
        }
        else
        {
            QuestName.text = questData.questName;
        }

    }
}
